﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;

public partial class mobile_sortsearch : System.Web.UI.Page
{
    string enter_id;
    string sname;
    protected void Page_Load(object sender, EventArgs e)
    {
        enter_id = this.Request.Params["eid"].ToString();
        sname = this.Request.Params["sname"].ToString();

        string[] pname = new string[500];
        string[] pimage = new string[500];
        string[] pid = new string[500];
        SqlConnection sc1 = new SqlConnection(ConfigurationManager.ConnectionStrings["wbkpt"].ConnectionString.ToString());
        sc1.Open();

        SqlCommand get = new SqlCommand();
        get.Connection = sc1;
        get.CommandText = "select PRODUCT_ID,PRODUCT_NAME,PRODUCT_IMAGE from INFO_PRODUCT where PRODUCT_SORT=@sname and ENTER_ID=@eid";
        get.Parameters.AddWithValue("@sname",sname);
        get.Parameters.AddWithValue("@eid",enter_id);
        SqlDataReader re = get.ExecuteReader();
        int i = 0;

        while (re.Read())
        {
            pid[i] = re.GetString(re.GetOrdinal("PRODUCT_ID"));
            pname[i] = re.GetString(re.GetOrdinal("PRODUCT_NAME"));
            pimage[i] = re.GetString(re.GetOrdinal("PRODUCT_IMAGE"));
            i++;
        }
        re.Close();
        SqlCommand get2 = new SqlCommand();
        get2.Connection = sc1;
        get2.CommandText = "select ENTER_NAME from INFO_ENTER where ENTER_ID=@sname2";
        get2.Parameters.AddWithValue("@sname2",enter_id);
        string namef = get2.ExecuteScalar().ToString();
        string result ="<h3>这些是来自" + namef + "平台的" + sname + "分类的产品：" + "</h3>";
        for (int k = 0; k < i; k++)
        {
            result += "<p><a style=\"width:78%;text-align:center; \" href=\"http://lcsy2008.eicp.net/wbkpro/mobile_product.aspx?pid="+pid[k]+"\">"+pname[k];
            string tmp = pimage[k].Remove(0, 2);
            result += "<br /><img width=\"80%\" src=\""+tmp+"\"/></a></p>";
        }
        label1.Text = result;

    }
}